<script setup lang="ts">
import useStore from '../store'
import { storeToRefs } from 'pinia'
const { todos } = useStore()

const { list, leftCount, showClear, navs, active } = storeToRefs(todos)
</script>

<template>
  <footer class="footer" v-if="list.length > 0">
    <span class="todo-count">
      <strong>{{ leftCount }}</strong> item left
    </span>
    <ul class="filters">
      <li v-for="item in navs" :key="item" @click="todos.changeActive(item)">
        <a :class="{ selected: item === active }" href="#/">{{ item }}</a>
      </li>
    </ul>
    <button class="clear-completed" @click="todos.clearTodo" v-if="showClear">
      Clear completed
    </button>
  </footer>
</template>

<style lang="less" scoped></style>
